<# # It is recommended to test the script on a local machine for its purpose and effects. # Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script to kill running many task on the task manager # Configuration Type - Computer # Arguments TaskName1 TaskName2 TaskName3 # EXAMPLE chrome firefox spoolersv # Note: Retrieve the task name from the task properties in Task Manager. #> # Check if there are any arguments passed to the script if ($args.Count -eq 0) { Write-Host "No process names provided. Please provide at least one process name as an argument." exit } # Iterate over each argument provided to the script foreach ($ProcessName in $args) { try { # Attempt to get the process by name $Processes = Get-Process -Name $ProcessName -ErrorAction Stop # If found, kill each process foreach ($Process in $Processes) { $Process.Kill() Write-Host "Process $($Process.Name) has been terminated." } } catch { # If an error occurs (e.g., the process is not found), handle it here Write-Host "Process $ProcessName is not running or cannot be terminated. Error: $_" } } # Indicate the script has completed Write-Host "Process check and termination script has completed."